import type {PageParam, PageResult} from '@vben/request';
import type {Dayjs} from 'dayjs';

import {requestClient} from '#/api/request';
export namespace PerBusinessFamilyStockApi {
  /** 股票情况业务信息 */
  export interface BusinessFamilyStock {
    id: number; // 主键ID
    busiId?: string; // 业务主表id
    familyStockId: number; // 正式表ID，对应 per_family_stock.id
    employeeId: number; // 人员ID，对应 per_employee.id
    relation: string; // 与本人关系（称谓）
    systemPersonId: number; // 系统人员ID，对应system_person.id
    familyName: string; // 姓名
    cardType: string; // 证件类型
    familyIdcard: string; // 家庭成员身份证号
    stockCode: string; // 股票代码
    stockName: string; // 股票名称
    shareQuantity: string; // 持股数量
    marketValue: number; // 填报前一交易日市值
    recordDate: string; // 记录时间
    status: number; // 是否有效（1：有效，0：无效）
    changeType: string; // 变更类型（add：新增，update：修改，delete：删除）
    changeContent: string; // 变更内容(JSON格式，记录变更前后对比，只有修改的时候记录)
    auditStatus: number; // 审核状态（0 草稿 1 审核中 2 审核完成）
    finalAuditStatus: number; // 最终审核状态：0 待审核 1 审核通过 2 审核不通过
    auditTime: string | Dayjs; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
  }
}

/** 查询股票情况业务分页 */
export function getBusinessFamilyStockPage(data: PageParam,desensitize: boolean,encrypt: boolean) {
  return requestClient.post<PageResult<PerBusinessFamilyStockApi.BusinessFamilyStock>>('/per/business-family-stock/page', data,{ desensitize,encrypt });
}

/** 查询股票情况业务详情 */
export function getBusinessFamilyStock(id: number) {
  return requestClient.get<PerBusinessFamilyStockApi.BusinessFamilyStock>(`/per/business-family-stock/get?id=${id}`);
}

/** 新增股票情况业务 */
export function createBusinessFamilyStock(data: PerBusinessFamilyStockApi.BusinessFamilyStock) {
  return requestClient.post('/per/business-family-stock/create', data);
}

/** 修改股票情况业务 */
export function updateBusinessFamilyStock(data: PerBusinessFamilyStockApi.BusinessFamilyStock) {
  return requestClient.put('/per/business-family-stock/update', data);
}

/** 删除股票情况业务 */
export function deleteBusinessFamilyStock(id: number) {
  return requestClient.delete(`/per/business-family-stock/delete?id=${id}`);
}

/** 批量删除股票情况业务 */
export function deleteBusinessFamilyStockList(ids: number[]) {
  return requestClient.delete(`/per/business-family-stock/delete-list?ids=${ids.join(',')}`)
}

/** 导出股票情况业务 */
export function exportBusinessFamilyStock(params: any) {
  return requestClient.download('/per/business-family-stock/export-excel', { params });
}

/** 根据业务主表id去查询业务数据 */
export function getFamilyStockBusiId(data: any) {
  return requestClient.post<PerBusinessFamilyStockApi.BusinessFamilyStock>(
    `/per/business-family-stock/getFamilyStockBusiId`,
    data,
  );
}

/** 获取当前登录人股票情况 */
export function getCurrentFamilyStock(
  data: any,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PerBusinessFamilyStockApi.BusinessFamilyStock[]>(
    '/per/business-family-stock/getCurrentFamilyStock',
    data,
    {
      desensitize,
      encrypt,
    },
  );
}
